package com.yiyi.credit.manage.sso.manager.controller;


import com.yiyi.credit.manage.sso.model.entity.SysRole;
import com.yiyi.credit.manage.sso.service.inner.SysInfoService;
import com.yiyi.credit.manage.sso.service.inner.SysRoleService;
import com.yiyi.credit.manage.sso.service.inner.SysUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;


@Controller
public class ViewController {

    @Autowired
    SysInfoService sysInfoService;

    @Autowired
    SysRoleService sysRoleService;

    @Autowired
    SysUserInfoService sysUserInfoService;



    @RequestMapping(value = "manager/sysInfoList")
    public ModelAndView sysInfoList() throws Exception {

        return new ModelAndView("/manager/sysInfoList");
    }


    @RequestMapping(value = "manager/sysInfoDetail")
    public ModelAndView sysInfoDetail(String sysInfoId) throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("sysInfoId", sysInfoId);
        return new ModelAndView("/manager/sysInfoDetail", map);
    }


    @RequestMapping(value = "manager/roleInfo")
    public ModelAndView roleInfo(String sysInfoId, String sysRoleId) throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("sysInfoId", sysInfoId);
        map.put("sysRoleId", sysRoleId);
        return new ModelAndView("/manager/roleInfo", map);
    }



    @RequestMapping(value = "manager/sysResource")
    public ModelAndView sysResource() throws Exception {

        return new ModelAndView("/manager/sysResource");
    }


    @RequestMapping(value = "manager/sysResourceDetail")
    public ModelAndView sysResourceDetail(@RequestParam String id, String pid, String sysInfoId) throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("pid", pid);
        map.put("sysInfoId", sysInfoId);
        return new ModelAndView("/manager/sysResourceDetail", map);
    }



    @RequestMapping(value = "manager/sysRoleResource")
    public ModelAndView sysRoleResource(String id) throws Exception {

        SysRole sysRole = sysRoleService.getSysRoleById(Long.parseLong(id));
        Map<String, Object> map = new HashMap<>();
        map.put("roleId", id);
        map.put("sysInfoId", sysRole.getSysId());
        return new ModelAndView("/manager/sysRoleResource", map);
    }


    @RequestMapping(value = "manager/sysRoleColumns")
    public ModelAndView sysRoleColumns(String id) throws Exception {

        SysRole sysRole = sysRoleService.getSysRoleById(Long.parseLong(id));
        Map<String, Object> map = new HashMap<>();
        map.put("roleId", id);
        map.put("sysInfoId", sysRole.getSysId());
        return new ModelAndView("/manager/sysRoleColumns", map);
    }


    @RequestMapping(value = "manager/sysRoleList")
    public ModelAndView sysRoleList() throws Exception {

        return new ModelAndView("/manager/sysRoleList");
    }



    @RequestMapping(value = "manager/sysRole")
    public ModelAndView sysRole() throws Exception {
        return new ModelAndView("/manager/sysRole");
    }


    @RequestMapping(value = "manager/sysRoleInfo")
    public ModelAndView sysRoleInfo(String sysInfoId, String sysRoleId,String subStationStatus) throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("sysInfoId", sysInfoId);
        map.put("sysRoleId", sysRoleId);
        map.put("subStationStatus", subStationStatus);
        return new ModelAndView("/manager/sysRoleInfo", map);
    }


    @RequestMapping(value = "manager/sysUserRole")
    public ModelAndView sysUserRole() throws Exception {
        return new ModelAndView("/manager/sysUserRole");
    }


    @RequestMapping(value = "manager/sysUserRoleAssign")
    public ModelAndView sysUserRoleAssign(String userId, String sysInfoId, String userRoleId, String roleId,String subStationStatus) throws Exception {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("sysInfoId", sysInfoId);
        map.put("userRoleId", userRoleId);
        map.put("roleId", roleId);
        map.put("subStationStatus", subStationStatus);
        return new ModelAndView("/manager/sysUserRoleAssign", map);
    }


    @RequestMapping(value = "manager/sysUserRoleBatchAssign")
    public ModelAndView sysUserRoleBatchAssign(String userIds, String sysInfoId,String subStationStatus) throws Exception {
        Map<String, Object> map = new HashMap<>();
        map.put("userIds", userIds);
        map.put("sysInfoId", sysInfoId);
        map.put("subStationStatus", subStationStatus);
        return new ModelAndView("/manager/sysUserRoleBatchAssign", map);
    }


    @RequestMapping(value = "manager/sysUserList")
    public ModelAndView sysUserList() throws Exception {
        return new ModelAndView("/manager/sysUserList");
    }


    @RequestMapping(value = "manager/sysUser")
    public ModelAndView sysUser(String sysUserId) throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("sysUserId", sysUserId);
        return new ModelAndView("/manager/sysUser", map);
    }



    @RequestMapping(value = "manager/updatePassword")
    public ModelAndView updatePassword(String sysUserId) throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("sysUserId", sysUserId);
        return new ModelAndView("/manager/updatePassword", map);
    }


    @RequestMapping(value = "manager/sysUserDetail")
    public ModelAndView sysUserDetail(String sysUserId) throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("sysUserId", sysUserId);
        return new ModelAndView("/manager/sysUserDetail", map);
    }


    @RequestMapping(value = "manager/shopList")
    public ModelAndView shopList() throws Exception {
        return new ModelAndView("/manager/shopList");
    }


    @RequestMapping(value = "manager/shop")
    public ModelAndView shop(String sid) throws Exception {

        Map<String, Object> map = new HashMap<>();
        map.put("sid", sid);
        return new ModelAndView("/manager/shop", map);
    }

}
